package com.ssy.lingxi.after.sale.utils;

import com.ssy.lingxi.common.constant.order.OrderTypeEnum;
import com.ssy.lingxi.common.model.dto.UserLoginCacheDTO;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 入参公共校验类-售后服务
 * @author ds
 * @version 2.0.0
 * @date 2021/4/26
 */
public class ParamVerifyUtils {
    /**
     * 判断订单为合同订单（合同订单：询价、竞价、招标）
     * @param orderType 订单类型
     */
    public static boolean  isContractOrderType(Integer orderType){
        List<Integer> contractOrderType= Stream.of(OrderTypeEnum.QUERY_PRICE_CONTRACT,
                OrderTypeEnum.PRICE_COMPETITION_CONTRACT_PURCHASE,
                OrderTypeEnum.PURCHASE_CONTRACT_BIDDING).map(OrderTypeEnum::getCode)
                .collect(Collectors.toList());
        return contractOrderType.contains(orderType);
    }

    public static boolean  isValidMember(UserLoginCacheDTO user,Long memberId,Long roleId){
        if(user==null){
            return Boolean.FALSE;
        }
        return user.getMemberId().equals(memberId)&&user.getMemberRoleId().equals(roleId);
    }
}
